<?php

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 * Description of LowSupplier
 *
 * @author fabiano
 */

require_once SITE_ROOT_PATH.'/_lib/classes/model/MasterSupplier.php';
require_once SITE_ROOT_PATH.'/_lib/classes/Supplier/low/class.QueryBuilder.php';
require_once SITE_ROOT_PATH.'/_lib/base/curl_multirequest.php';

class LowSupplier extends MasterSupplier{    
    
   
    public function doBooking(){
        // don't do anything yet but it has to be here just because the MasterSupplier class is abstract        
    }
    
    public function doCancelBooking(){
        // don't do anything yet but it has to be here just because the MasterSupplier class is abstract        
    }                 
    
    public function buildSearchXML($params){
        $search_query = ''; 
        $paramsPrepared = $this->mapSearchParams($params);
        $lowQB = new lowQueryBuilder(array($this->auth['username_name']  => $this->auth['username_value'],
                                           $this->auth['password_name']  => $this->auth['password_value'],
                                           $this->auth['reference_name'] => $this->auth['reference_value'],));
        $search_query = array('url'=>$this->getServiceUrlByKey('search'),
                              'post'=>$lowQB->search($paramsPrepared)); 
        $this->setXmlSearch($search_query);        
    }
       
    public function sendSearchRequest(){  
        $this->xmlLog($this->getXmlSearch(), 'sending_search', MODE_RUN);
        $sendXML = array ($this->getCode() => $this->getXmlSearch());
        $result = curl_multirequest($sendXML);
        return $result;    
    }   

    public function buildBookingXML($params){  
        $paramsPrepared = $this->mapBookingParams($params);
       // print_r($paramsPrepared); die();
        $lowQB = new lowQueryBuilder(array($this->auth['username_name']  => $this->auth['username_value'],
                                           $this->auth['password_name']  => $this->auth['password_value'],
                                           $this->auth['reference_name'] => $this->auth['reference_value'],));
        $url = array('url'=>$this->getServiceUrlByKey('booking'),
                     'post'=>$lowQB->book($paramsPrepared) );
        $this->setXmlBooking($url);
    }
    
    public function sendBookingRequest(){
       $this->xmlLog($this->getXmlBooking(), 'sending_booking', MODE_RUN);
       $queries = array(1=>$this->getXmlBooking());
       $results = curl_multirequest($queries);  
       return $results[1];
    }
    
    public function buildCancelXML($params){
        // don't do anything yet but it has to be here just because the MasterSupplier class is abstract        
    }
}

?>
